package judesart.app.domain;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.validation.constraints.NotNull;

@Entity
@NamedQueries( {
        @NamedQuery(name = "Project.countByArtistId", query = "select count(o) from Project o where o.artistId = :artistId"),
        @NamedQuery(name = "Project.findByArtistId", query = "select o from Project o where o.artistId = :artistId") })
public class Project implements Serializable
{

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    @Basic
    @NotNull
    private Long artistId;
    @Basic
    @NotNull
    private String title;
    @Basic
    private String description;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "project")
    private List<Sketch> sketchs;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "project")
    private List<ProjectPhoto> photos;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "project")
    private List<Note> notes;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "project")
    private List<ProjectArtwork> artworks;

    public Long getId()
    {
        return id;
    }

    public void setId(Long id)
    {
        this.id = id;
    }

    public Long getArtistId()
    {
        return artistId;
    }

    public void setArtistId(Long artistId)
    {
        this.artistId = artistId;
    }

    public String getTitle()
    {
        return title;
    }

    public void setTitle(String title)
    {
        this.title = title;
    }

    public String getDescription()
    {
        return description;
    }

    public void setDescription(String description)
    {
        this.description = description;
    }

    public List<Sketch> getSketchs()
    {
        return sketchs;
    }

    public void setSketchs(List<Sketch> sketchs)
    {
        this.sketchs = sketchs;
    }

    public List<ProjectPhoto> getPhotos()
    {
        return photos;
    }

    public void setPhotos(List<ProjectPhoto> photos)
    {
        this.photos = photos;
    }

    public List<Note> getNotes()
    {
        return notes;
    }

    public void setNotes(List<Note> notes)
    {
        this.notes = notes;
    }

    public List<ProjectArtwork> getArtworks()
    {
        return artworks;
    }

    public void setArtworks(List<ProjectArtwork> artworks)
    {
        this.artworks = artworks;
    }

    @Override
    public int hashCode()
    {
        final int prime = 31;
        int result = 1;
        result = prime * result + (id == null ? 0 : id.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj)
    {
        if (this == obj)
        {
            return true;
        }
        if (obj == null)
        {
            return false;
        }
        if (getClass() != obj.getClass())
        {
            return false;
        }
        Project other = (Project) obj;
        if (id == null)
        {
            if (other.id != null)
            {
                return false;
            }
        } else if (!id.equals(other.id))
        {
            return false;
        }
        return true;
    }
}
